package com.xayy.health.ds.controller;

import com.xtck.ha.common.core.constant.HttpStatus;
import com.xtck.ha.common.core.utils.poi.ExcelUtil;
import com.xtck.ha.common.core.web.controller.BaseController;
import com.xtck.ha.common.core.web.domain.AjaxResult;
import com.xtck.ha.common.core.web.page.TableDataInfo;
import com.xayy.health.ds.model.DsModelTrainRecord;
import com.xayy.health.ds.service.DsModelTrainRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 模型列表 controller
 *
 * @ClassName: DsModelTrainRecordController
 * @Description: 外部访问接口
 * @author liuyuan
 * @date 2025-07-08
 */
@Api(tags = "模型训练记录表管理")
@RestController
@RequestMapping("/health-mgr-back/v1.0/dsModelTrainRecord")
public class DsModelTrainRecordController extends BaseController {

    @Autowired
    private DsModelTrainRecordService dsModelTrainRecordService;


    @ApiOperation("分页查询模型训练记录表列表")
    @GetMapping("/page")
    public AjaxResult page(DsModelTrainRecord dsModelTrainRecord)
    {
        startPage();
        List<DsModelTrainRecord> list = dsModelTrainRecordService.selectTList(dsModelTrainRecord);
        TableDataInfo rspData = new TableDataInfo();
        rspData.setCode(HttpStatus.SUCCESS);
        rspData.setList(list);
        rspData.setMsg("查询成功");
        rspData.setTotal(dsModelTrainRecordService.count(dsModelTrainRecord));
        return AjaxResult.success(rspData);
    }

    @ApiOperation("列表查询模型训练记录表")
    @GetMapping("/list")
    public List<DsModelTrainRecord> list(DsModelTrainRecord dsModelTrainRecord)
    {
        List<DsModelTrainRecord> list = dsModelTrainRecordService.selectTList(dsModelTrainRecord);
        return list;
    }

    @ApiOperation("导出模型训练记录表列表")
    @PostMapping("/export")
    public void export(HttpServletResponse response, DsModelTrainRecord dsModelTrainRecord)
    {
        List<DsModelTrainRecord> list = dsModelTrainRecordService.selectTList(dsModelTrainRecord);
        ExcelUtil<DsModelTrainRecord> util = new ExcelUtil<>(DsModelTrainRecord.class);
        util.exportExcel(response, list, "样例数据");
    }

    @ApiOperation("获取$模型训练记录表详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dsModelTrainRecordService.selectTById(id));
    }

    @ApiOperation("新增$模型训练记录表")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DsModelTrainRecord dsModelTrainRecord)
    {
        return toAjax(dsModelTrainRecordService.insertT(dsModelTrainRecord));
    }

    @ApiOperation("修改模型训练记录表")
    @PutMapping
    public AjaxResult update(@RequestBody DsModelTrainRecord dsModelTrainRecord)
    {
        int i = dsModelTrainRecordService.updateT(dsModelTrainRecord);
        return toAjax(i);
    }

    @ApiOperation("删除模型训练记录表")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dsModelTrainRecordService.deleteTByIds(ids));
    }





}
